// G4提供的头文件
#include "G4Box.hh"
#include "G4LogicalVolume.hh"
#include "G4PVPlacement.hh"
#include "G4SystemOfUnits.hh"
#include "G4NistManager.hh"

// 用户编写的头文件
#include "G4StartDetectorConstruction.hh"

G4VPhysicalVolume * G4StartDetectorConstruction::Construct(){

    // 创建材料查找表
    auto nist = G4NistManager::Instance();

    /*************创建G4World********************/
    // 创建world几何体
    G4Box * solid_world = new G4Box("world",
                                     0.5*m,
                                     0.5*m,
                                     0.5*m
                                    );
    // 填充材料，生成world逻辑体
    G4LogicalVolume * logic_world = new G4LogicalVolume(solid_world,
                                                        nist->FindOrBuildMaterial("G4_AIR"),
                                                        "world"
                                                        );
    // 摆放位置，生成world物理体
    G4VPhysicalVolume * phy_world = new G4PVPlacement(0,
                                                        G4ThreeVector(0,0,0),
                                                        logic_world,
                                                        "world",
                                                        0,
                                                        false,
                                                        0
                                                        );

    /*************创建G4靶材料********************/
    // 创建靶材料几何体
    G4Box * solid_target = new G4Box("target",
                                     0.1*m,
                                     0.25*m,
                                     0.25*m
                                    );
    // 填充材料，生成target逻辑体
    G4LogicalVolume * logic_target = new G4LogicalVolume(solid_target,
                                                        nist->FindOrBuildMaterial("G4_Al"),
                                                        "target"
                                                        );
    // 摆放位置，生成target物理体
    G4VPhysicalVolume * phy_target = new G4PVPlacement(0,
                                                        G4ThreeVector(25*cm,0,0),
                                                        logic_target,
                                                        "target",
                                                        logic_world,
                                                        false,
                                                        1
                                                        );

    return phy_world;



}